package com.hwbsite.hwbback.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hwbsite.hwbback.service.CommonService;
import com.hwbsite.hwbback.utils.DhRes;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import jakarta.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/tt/common")
@AllArgsConstructor
public class CommonController {

    private final CommonService commonService;

    @GetMapping("/emoji")
    public DhRes getEmoji(){
        return DhRes.success(commonService.getEmoji());
    }


    @GetMapping("/getFile")
    public byte[] getFile(@RequestParam("path")String  path , HttpServletResponse response){
        response.addHeader("Cache-Control" , "max-age=604800");
        return commonService.getFile(path);
    }

    @GetMapping("/no/getFile")
    public byte[] getFFile(@RequestParam("path")String  path , HttpServletResponse response){
//        response.addHeader("Cache-Control" , "max-age=604800");
        return commonService.geNotFile(path);
    }
}
